$def with (course,task_data,available_filetypes,AccessibleTime,current_filetype,contains_is_html)

$#
$# This file is part of INGInious. See the LICENSE and the COPYRIGHTS files for
$# more information about the licensing of this file.
$#

<div class="form-group row">
    <label for="name" class="col-sm-2 control-label">Name</label>
    <div class="col-sm-7">
        <input type="text" class="form-control" id="name" name="name" placeholder="title for this task" value="${task_data.get('name','')}">
    </div>
    <div class="col-sm-3">
        <button type="button" data-toggle="modal" data-target="#delete_modal" class="btn btn-block btn-danger">
            <i class="fa fa-trash"></i> $:_("Delete task")
        </button>
    </div>

</div>
$if len(available_filetypes) != 1:
    <div class="form-group row">
        <label for="name" class="col-sm-2 control-label">$:_("Filetype")</label>
        <div class="col-sm-10">
            <select class="form-control" id="@filetype" name="@filetype">
                $for type in available_filetypes:
                    <option value="$type"
                        $if type == current_filetype or (current_filetype is None and type == "yaml"):
                            selected="selected"
                    >$type</option>
            </select>
        </div>
    </div>
$else:
    <input type="hidden" id="@filetype" name="@filetype" value="$available_filetypes[0]"/>
<div class="form-group row">
    <label for="context" class="col-sm-2 control-label">$:_("Context")</label>
    <div class="col-sm-10">
        <textarea id="context" class="code-editor form-control" name="context" data-x-language="rst" data-x-lines="10">${task_data.get('context','')}</textarea>
    </div>
</div>
<div class="form-group row">
    <label for="author" class="col-sm-2 control-label">$:_("Author")</label>
    <div class="col-sm-10">
        $if isinstance(task_data.get('author',[]),list):
            $ a=', '.join(task_data.get('author',[]))
        $else:
            $ a=task_data.get('author',[])
        <input type="text" class="form-control" id="author" name="author" placeholder="$:_('Your name')" value="$a"/>
    </div>
</div>
<div class="form-group row">
    <label for="contact-url" class="col-sm-2 control-label">$:_("Contact URL")</label>
    <div class="col-sm-10">
        <input type="text" class="form-control" id="contact-url" name="contact_url" placeholder="$:_('Contact link')" value="$task_data.get('contact_url','')"/>
    </div>
</div>
<div class="form-group row">
    <label for="categories" class="col-sm-2 control-label">$:_("Categories")</label>
    <div class="col-sm-10">
        <input type="text" class="form-control" id="categories" name="categories" placeholder=$:_('"Tag ids, separated by commas"')
               value="$','.join(task_data.get('categories', []))">
    </div>
</div>
<div class="form-group row">
    <label for="author" class="col-sm-2 control-label">$:_("Grade weight (in comparison to other tasks)")</label>
    <div class="col-sm-10">
        <input type="text" class="form-control" id="weight" name="weight" placeholder="1.00" value="${task_data.get('weight',1.00)}">
    </div>
</div>
<div class="form-group row">
    <label for="groups" class="col-sm-2 control-label">$:_("Submission mode")</label>
    <div class="col-sm-10">
        <label>
            <input type="radio" value="false" name="groups" id="groups"
                $if not task_data.get('groups', False):
                    checked="checked"
            /> $:_("Individually")
        </label><br/>
        <label>
            <input type="radio" value="true" name="groups"
                $if task_data.get('groups', False):
                    checked="checked"
            /> $:_("Per group")
        </label>
    </div>
</div>
<div class="form-group row">
    <label for="groups" class="col-sm-2 control-label">$:_("Submission storage")</label>
    <div class="col-sm-10">
        $ stored_submissions = task_data.get('stored_submissions', 0)
        <label>
            <input type="radio" value="true" name="store_all" id="store_all"
                $if stored_submissions == 0:
                    checked="checked"
            /> $:_("All submissions")
        </label><br/>
        <div class="row">
            <div class="col-xs-12 col-lg-3">
                <label>
                    <input type="radio" value="false" name="store_all"
                        $if stored_submissions > 0:
                            checked="checked"
                    />
                    $:_("Only the last {nbr_submissions} submissions").format(nbr_submissions='</label></div><div class="col-xs-offset-1 col-lg-offset-0 col-xs-11 col-lg-2"><input name="stored_submissions" class="form-control input-xs" style="height:20px;padding: 0 10px;" value="' + (str(stored_submissions) if stored_submissions > 0 else '') + '" placeholder="5" type="number"></div><div class="col-xs-offset-1 col-lg-offset-0 col-xs-11 col-lg-3"><label>')
                </label>
            </div>
        </div>
    </div>
</div>
<div class="form-group row">
    <label for="groups" class="col-sm-2 control-label">$:_("Submission limits")</label>
    <div class="col-sm-10">
        $ submission_limit = task_data.get('submission_limit', {"amount":-1, "period":-1})
        <label>
            <input type="radio" value="none" name="submission_limit" id="submission_limit" $('checked="checked"' if submission_limit == {"amount":-1, "period":-1} else '') /> $:_("No limitation")
        </label><br/>
        <div class="row">
            <div class="col-xs-12 col-lg-3">
                <label>
                    <input type="radio" value="hard" name="submission_limit"
                        $if submission_limit["period"] == -1 and submission_limit['amount'] > 0:
                            checked="checked"
                    />
                    $:_("Hard limit: {nbr_submissions} submission(s)").format(nbr_submissions='</label></div><div class="col-xs-offset-1 col-lg-offset-0 col-xs-11 col-lg-2"><input name="submission_limit_hard" class="form-control input-xs" style="height:20px;padding: 0 10px;" value="' + str(submission_limit['amount'] if submission_limit['period'] == -1 and submission_limit['amount'] > 0 else '') + '" placeholder="5"  type="number"></div><div class="col-xs-offset-1 col-lg-offset-0 col-xs-11 col-lg-3"><label>')
                </label>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12 col-lg-3">
                <label>
                    <input type="radio" value="soft" name="submission_limit"
                        $if submission_limit['period'] > 0:
                            checked="checked"
                    />
                    $:_("Soft limit: {nbr_submissions} submission(s) every {nbr_hours} hour(s)").format(nbr_submissions='</label></div><div class="col-xs-offset-1 col-lg-offset-0 col-xs-11 col-lg-2"><input name="submission_limit_soft_0" class="form-control input-xs" style="height:20px;padding: 0 10px;" value="' + str(submission_limit['amount'] if submission_limit['amount'] > 0 and submission_limit['period'] > 0 else '') + '" placeholder="5" type="number"></div><div class="col-xs-offset-1 col-lg-offset-0 col-xs-11 col-lg-3"><label>', nbr_hours='</label></div><div class="col-xs-offset-1 col-lg-offset-0 col-xs-11 col-lg-2"><input name="submission_limit_soft_1" class="form-control input-xs" style="height:20px;padding: 0 10px;" value="' + str(submission_limit['period'] if submission_limit['period'] > 0 else '') + '" placeholder="5" type="number"></div><div class="col-xs-offset-1 col-lg-offset-0 col-xs-11 col-lg-1"><label>')
                </label>
            </div>
        </div>
    </div>
</div>
<div class="form-group row">
    <label for="groups" class="col-sm-2 control-label">$:_("Evaluation submission")</label>
    <div class="col-sm-10">
        <label>
            <input type="radio" value="best" name="evaluate" id="evaluate"
                $if task_data.get('evaluate', 'best') == 'best':
                    checked="checked"
            /> $:_("Best submission")
        </label><br/>
        <label>
            <input type="radio" value="last" name="evaluate"
                $if task_data.get('evaluate', 'best') == 'last':
                    checked="checked"
            /> $:_("Last submission")
        </label><br/>
        <label>
            <input type="radio" value="student" name="evaluate"
                $if task_data.get('evaluate', 'best') == 'student':
                    checked="checked"
            /> $:_("Student choice")
        </label>
    </div>
</div>
<div class="form-group row">
    <label for="accessible" class="col-sm-2 control-label">$:_("Accessible")</label>
    <div class="col-sm-10">
        <label>
            <input type="radio" value="false" name="accessible"
                $if task_data.get('accessible',True) == False:
                    checked="checked"
            /> $:_("Never")
        </label><br/>
        <label>
            <input type="radio" value="true" name="accessible"
                $if task_data.get('accessible',True) == True:
                    checked="checked"
            /> $:_("Always")
        </label><br/>
        <div class="row">
            <div class="col-xs-12 col-lg-3">
                <label class="control-label">
                    <input type="radio" value="custom" name="accessible"
                        $if task_data.get('accessible',True) not in [True, False]:
                            checked="checked"
                    />
                    $ text = _("Custom, from: {} to: {}").split("{}")
                    $:text[0]</label>
            </div>
            $ at = AccessibleTime(task_data.get('accessible',True))
            <div class="col-xs-offset-1 col-lg-offset-0 col-xs-11 col-lg-4">
                <div class='input-group date' id='accessible_start_picker' data-target-input="nearest">
                        <input data-target='#accessible_start_picker' name="accessible_start" data-date-format="YYYY-MM-DD HH:mm:ss" value="${at.get_std_start_date()}" placeholder="2014-06-29 10:00" type='text' class="form-control datetimepicker-input" />
                        <div class="input-group-append" data-target="#accessible_start_picker" data-toggle="datetimepicker">
                                <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                        </div>

                </div>
            </div>
            <div class="col-xs-offset-1 col-lg-offset-0 col-xs-11 col-lg-1"><label class="control-label">$text[1]</label></div>
            <div class="col-xs-offset-1 col-lg-offset-0 col-xs-11 col-lg-4">
                <div class='input-group date' id='accessible_end_picker' data-target-input="nearest">
                        <input data-target='#accessible_end_picker' name="accessible_end" data-date-format="YYYY-MM-DD HH:mm:ss" value="${at.get_std_end_date()}" placeholder="2014-06-29 10:00" type='text' class="form-control datetimepicker-input" />
                        <div class="input-group-append" data-target="#accessible_end_picker" data-toggle="datetimepicker">
                                <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                        </div>

                </div>
            </div>
        </div>
        <div class="row">
            <!-- Padding -->
            <div class="col-xs-12 col-lg-3"></div>
            <div class="col-xs-offset-1 col-lg-offset-0 col-xs-11 col-lg-4"></div>
            <!-- End of padding -->
            <div class="col-xs-offset-1 col-lg-offset-0 col-xs-11 col-lg-1"><label class="control-label">$:_("Soft Deadline")</label></div>
            <div class="col-xs-offset-1 col-lg-offset-0 col-xs-11 col-lg-4">
                <div class="form-group">
                    <div class='input-group date' id='accessible_soft_end_picker' data-target-input="nearest">
                            <input data-target='#accessible_soft_end_picker' name="accessible_soft_end" data-date-format="YYYY-MM-DD HH:mm:ss" value="${at.get_std_soft_end_date()}" placeholder="2014-06-29 10:00" type='text' class="form-control datetimepicker-input" />
                            <div class="input-group-append" data-target="#accessible_soft_end_picker" data-toggle="datetimepicker">
                                    <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                            </div>

                    </div>
                </div>
            </div>
        </div>
        <script type="text/javascript">
            \$(function() {
                \$('#accessible_start_picker').datetimepicker({locale: '$user_manager.session_language()', sideBySide: true, format:'YYYY-MM-DD HH:mm:ss'});
                \$('#accessible_end_picker').datetimepicker({locale: '$user_manager.session_language()', sideBySide: true, format:'YYYY-MM-DD HH:mm:ss'});
                \$('#accessible_soft_end_picker').datetimepicker({locale: '$user_manager.session_language()', sideBySide: true, format:'YYYY-MM-DD HH:mm:ss'});
            });
        </script>
    </div>
</div>
<div class="form-group row">
    <label for="groups" class="col-md-2 control-label">$:_("Random inputs")</label>
    <div class="col-md-2">
        $ n_inputs_random = task_data.get('input_random', 0)
        <input name="input_random" class="form-control input-xs" style="height:20px;padding: 0 10px;" value="$n_inputs_random" placeholder="0" type="number">
    </div>
</div>
<div class="form-group row">
    <label for="regenerate_input_random" class="col-md-2 control-label" data-toggle="tooltip" data-placement="top" title="$:_('Regenerate random inputs for each reloading of the task page')">$:_("Regenerate input random")</label>
    <div class="col-md-1">
        <div class="form-check">
            <input class="form-check-input" type="checkbox" id="regenerate_input_random" name="regenerate_input_random"
                   $if task_data.get('regenerate_input_random',False):
                       checked="checked"
            />
        </div>
    </div>
</div>